<?php include $this->admin_tpl('meta');?>
<title>添加管理员</title>
</head>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			 <li><label><span class="c-red">*</span>供应商名称：</label>
			 	<input type="text" class="input" placeholder="请输入供应商名称" name="supplier_name" value="" autocomplete="off">
			 </li>
			 <li><label><span class="c-red">*</span>编码：</label>
			 	<input type="text" class="input" autocomplete="off" value="" placeholder="请输入编码" name="code">
			 </li>	
			 <li><label><span class="c-red"></span>备注：</label>
			 	<input type="text" class="input" autocomplete="off"  placeholder="请输入备注" name="remark">
			 </li>
			 <li><label><span class="c-red">*</span>状态</label>
			 <span class="span_input">
			 	<label class="label_radio"><input name="status" type="radio" value="1" checked="1"> 启用</label>
			 	<label class="label_radio"><input name="status" type="radio" value="0"> 禁用</label>
			 </span>
			 </li>
		</ul>
		<div class="footer_btn">
			<input type="hidden" name="dosubmit" value="1">
			<input class="btn btn-primary radius" type="submit" value="提 交">
			<input class="btn btn-default radius" type="button" value="取 消" onclick="yzmcms_close()">	
		</div>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer');?>

<script type="text/javascript">
$('.layui-layer-close').click();
	function dosub(obj){
		 if(obj.supplier_name.value==''){
			 layer.msg('供应商名称！', {icon:2});
			 return false;
		 }
		 if(obj.code.value==''){
			 layer.msg('供应商名称！', {icon:2});
			 return false;
		 }
        $.ajax({
            type: 'POST',
            url: '<?php echo U('collect_supplier',['type'=>'add']);?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:800}, function(){
						parent.table.reload('table');
						var index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe 层的索引
						parent.layer.close(index); // 再执行关闭
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>